Skip to main content

APIs

When you build a React application, most of what your users see lives in the browser. But the data behind those interfaces (like users, products, or weather info) lives somewhere else — on a server or in a database. That’s where Web APIs come in.

What Is a Web API?

A Web API (Application Programming Interface) is a set of HTTP endpoints that allow one application (the client) to communicate with another application or service (the server).

In practice, a Web API:

  • Accepts incoming HTTP requests such as GET, POST, PUT, and DELETE

  • Processes or retrieves data from a database or external service

  • Sends a structured response (usually JSON) back to the client

So, every time your React or Next.js component calls fetch('/api/items'), it’s talking to a Web API — even if that API is part of the same project.

External Web APIs

Dad Joke api
Dad Joke public joke api

Next.js components can also interact with external APIs, such as:

  • Weather API for weather data

  • GitHub REST API for repositories

  • Google Maps API for location data

This allows your apps to combine local data from your own database with external data from other services — expanding what your application can do.

Web APIs refer to an interface, We make requests to particular URLs, or endpoints.

Joke API example

Check this Geek Joke API. Copy the endpoint https://geek-jokes.sameerkumar.website/api?format=json , paste it in a browser and see what it returns.